
package test;

// {{{ imports

#if flash9
import flash.display.Sprite;
import flash.events.MouseEvent;
#else
import flash.MovieClip;
import jp.ize.iwp.avm1.events.MouseEvent;
import jp.ize.iwp.avm1.display.Sprite;
#end

import jp.ize.iwp.RuntimeEngine;
import jp.ize.iwp.utils.DebugUtil;

// }}}

class DebugTest extends Sprite
{
	// {{{ properties

	static var sp1:Sprite;
	static var sp2:Sprite;

	// }}}
	// {{{ public static function main() : Void

	public static function main() : Void
	{
		RuntimeEngine.init();
		DebugUtil.init();
		DebugUtil.setLocation(50,50);
		create();
	}

	// }}}
	// {{{ public static function create() : Void

	public static function create() : Void
	{
		var mystage = RuntimeEngine.getStage();

		sp1 = new Sprite();
		sp2 = new Sprite();
		mystage.addChild(sp1);
		mystage.addChild(sp2);
		// {{{ sp1
		sp1.graphics.beginFill( 0xFF9900 );
		sp1.graphics.drawRoundRect( 0, 0, 300, 200, 5 );
		sp1.graphics.endFill();
		sp1.x = 50;
		sp1.y = 160;
		// }}}
		// {{{ sp2
		sp2.graphics.beginFill( 0x00FF00 );
		sp2.graphics.drawEllipse( 0, 0, 300, 120 );
		sp2.graphics.endFill();
		sp2.x = 20;
		sp2.y = 80;
		// }}}

		sp1.addEventListener( MouseEvent.CLICK, myclick1 );
		sp2.addEventListener( MouseEvent.CLICK, myclick2 );

		sp2.addEventListener( MouseEvent.MOUSE_DOWN, function(e){ sp2.startDrag(false); } );
		sp2.addEventListener( MouseEvent.MOUSE_UP,   function(e){ sp2.stopDrag(); } );
	}

	// }}}
	// {{{ public static function myclick1( e:MouseEvent ) : Void

	public static function myclick1( e:MouseEvent ) : Void
	{
		trace("my click 1: this is sp1");
	}

	// }}}
	// {{{ public static function myclick2( e:MouseEvent ) : Void

	public static function myclick2( e:MouseEvent ) : Void
	{
		
		trace("my click 2: this is sp2");
		trace(e);
	}

	// }}}
}
